<template>
  <div class="container">
    <navBar :navBar="navBar"></navBar>
    <div class="contentArea">
      <div class="topInner">
        <div class="innerArea">
          <p class="title">{{ $t("正在托管的资金") }}</p>
          <p class="note">
            <span>{{ headInfo.sumMoney ? headInfo.sumMoney : 0.0 }}</span
            >{{ $t("USDT") }}
          </p>
          <p class="text" @click="goOther">{{ $t("我的订单") }}</p>
        </div>
        <div class="subInner">
          <div class="itemBox">
            <p class="num">{{ headInfo.todayWin ? headInfo.todayWin : 0.0 }}</p>
            <p class="text">{{ $t("预计今日收益") }}</p>
          </div>
          <div class="itemBox">
            <p class="num">{{ headInfo.sumWin ? headInfo.sumWin : 0.0 }}</p>
            <p class="text">{{ $t("累计收益") }}</p>
          </div>
          <div class="itemBox" @click="goOther">
            <p class="num">{{ headInfo.sumOrder ? headInfo.sumOrder : 0 }}</p>
            <p class="text">{{ $t("托管中的订单") }}</p>
          </div>
        </div>
      </div>
      <div class="content">
        <div class="contentInner">
          <div class="item" v-for="(item, index) in miniList" :key="index">
            <div class="topBox">
              <div class="leftInner">
                <img :src="$basePath + item.img" alt="" />
                <p class="level">{{ item.name }}</p>
              </div>
			  <div v-if="item.end_time">
				  <p style="font-size: 14px;">{{ $t("截止日期") }}</p>
				  <p style="font-size: 12px;text-align: center;padding-top: 5px;color:red">{{ item.end_time }}</p>
			  </div>
              <div class="rightInner">
                <van-button v-if="item.is_buy" type="info" size="small" @click="goBuy(item.id)">{{
                  $t("去买入")
                }}</van-button>
				<van-button v-else type="info" size="small" style="background: #eee;color: red;">{{
				  $t("已截止")
				}}</van-button>
              </div>
            </div>
            <div class="btmBox">
              <div class="itemSub">
                <p class="ttl">{{ $t("最小购买") }}</p>
                <p class="text">{{ Number(item.min).toFixed(2) }} - 999999.00</p>
              </div>
              <div class="itemSub">
                <p class="ttl">{{ $t("日收益率") }}</p>
                <p class="text">{{ item.rate }}%</p>
              </div>
              <div class="itemSub">
                <p class="ttl">{{ $t("周期") }}</p>
                <p class="text">{{ item.day }}{{ $t("天") }}</p>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import navBar from "@/components/navBar.vue";
export default {
  name: "wealthList",
  components: { navBar },
  data() {
    return {
      navBar: {
        back: true,
        title: this.$t("理财产品"),
        close: false,
        btn: "",
      },
      miniList: [],
      headInfo: {},
    };
  },
  mounted() {
    this.init();
    this.initHeadInfo();
  },
  methods: {
    // 初始化数据
    init() {
      $postAxios(api.getMiningList, {}, (res) => {
        if (res.code == 0) {
			
          this.miniList = res.data;
        } else {
          this.$toast(this.$t(res.msg));
        }
      });
    },
    initHeadInfo() {
      $postAxios(api.getUserMiningInfo, {}, (res) => {
        if (res.code == 0) {
          this.headInfo = res.data;
        } else {
          this.$toast(this.$t(res.msg));
        }
      });
    },
    // 购买
    goBuy(id) {
      this.$router.push("/productDetail?id=" + id);
    },
    // 跳转页面
    goOther() {
      this.$router.push("/financialTradeList");
    },
  },
};
</script>

<style lang="scss" scoped>
.container {
  width: 100%;
  height: 100%;
  box-sizing: border-box;
  background-color: #f7f6fb;
  .contentArea {
    width: 100%;
    position: absolute;
    left: 0;
    top: 40px;
    bottom: 0;
    box-sizing: border-box;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .content {
    padding: 10px;
    .contentInner {
      .item {
        margin-bottom: 10px;
        padding: 0 10px;
        background-color: #fff;
        border-radius: 10px;
        .topBox {
          margin-bottom: 10px;
          display: flex;
          align-items: center;
          justify-content: space-between;
          .leftInner {
            height: 50px;
            display: flex;
            align-items: center;
            img {
              margin-right: 10px;
              display: block;
              width: 40px;
              height: auto;
            }
            .level {
              color: #000;
              font-size: 16px;
              font-weight: 600;
            }
          }
          .rightInner {
            .van-button {
              padding-left: 14px;
              padding-right: 14px;
              display: block;
              border-radius: 5px;
              border-color: rgba(0, 0, 0, 0.2);
              background-color: #00abff;
            }
          }
        }
        .btmBox {
          padding: 5px 0;
          display: flex;
          align-items: center;
          justify-content: space-between;
          .itemSub {
            width: 40%;
            flex-shrink: 0;
            text-align: center;
            .ttl {
              color: #303133;
              font-size: 11px;
            }
            .text {
              margin: 7px 0;
              color: #00abff;
              font-size: 12px;
            }
            &:nth-child(2) {
              width: 30%;
            }
            &:nth-child(3) {
              width: 30%;
            }
          }
        }
      }
    }
  }
  .topInner {
    padding: 32px 20px 10px;
    width: 100%;
    height: 207px;
    box-sizing: border-box;
    background: url("../../assets/images/bg05.png") no-repeat center top -65px;
    background-size: cover;
    .innerArea {
      margin-bottom: 32px;
      .title {
        color: #fff;
        font-size: 16px;
      }
      .note {
        color: #fff;
        font-size: 20px;
        font-weight: 700;
        span {
          margin-right: 4px;
          font-size: 32px;
        }
      }
      .text {
        position: fixed;
        right: -10px;
        top: 80px;
        width: 120px;
        padding: 5px 10px;
        color: #5a8af8;
        font-size: 16px;
        text-align: center;
        box-sizing: border-box;
        z-index: 99;
        border-radius: 50px;
        background-color: #d5e7ff;
      }
    }
    .subInner {
      margin: 0 -20px;
      padding: 15px 35px;
      display: flex;
      align-items: center;
      justify-content: space-between;
      color: #fff;
      background: hsla(0, 0%, 100%, 0.2);
      .itemBox {
        text-align: center;
        .num {
          margin-bottom: 5px;
          font-size: 16px;
          font-weight: 700;
        }
        .text {
          font-size: 12px;
        }
      }
    }
  }
}
</style>